package com.zhang.dao.impl;

import com.zhang.dao.LoveDao;
import com.zhang.pojo.Love;
import com.zhang.utils.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;


public class LoveDaoImpl implements LoveDao {

    private JdbcTemplate jdbcTemplate = new JdbcTemplate(JDBCUtils.getDataSource());

    @Override
    public List<Love> findLove(int userId) {
        String sql = "SELECT * FROM `love`l,`user_love` ul WHERE  ul.loveId=l.`id` AND ul.userId =?";
        return jdbcTemplate.query(sql,new BeanPropertyRowMapper<Love>(Love.class),userId);

    }
}
